<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>开发一个简单的Website</title>
</head>
<body>

<!--任务宰守成夹-->
    <table>
        <tr>
            <th>name</th>
            <th>age</th>
            <th>操作</th>
        </tr>
        <tr>
            <td><input type="text" class="name"></td>
            <td><input type="text" class="age"></td>
            <td><button onclick="save()">添加数据</button></td>
        </tr>
    </table>
    <table>
        <tr>
            <td>请输入名字查询年龄</td>
            <td><input type="text" class="getName"></td>
            <td><button onclick="find()">查找数据</button></td>
        </tr>
        <tr class="dis"></tr>

    </table>


    <script>
        function save() {
            var name = document.getElementsByClassName("name")[0].value;
            var age = document.getElementsByClassName("age")[0].value;
            localStorage.setItem(name,age);
            alert('添加数据成功');
        }

        function find() {
            var getName = document.getElementsByClassName("getName")[0].value;
            var age = localStorage.getItem(getName);
            document.getElementsByClassName("dis")[0].innerHTML = "你的年龄是" + age;
        }
    </script>


</body>
</html>
